from tortoise import fields

from .base import BaseModel


class Permission(BaseModel):
    """Permission model for RBAC system."""

    name = fields.CharField(max_length=100, unique=True)
    code = fields.CharField(max_length=100, unique=True)
    description = fields.TextField(null=True)

    class Meta:
        table = "permissions"

    def __str__(self):
        return f"{self.name} ({self.code})"
